package cn.project.lemontree.bean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class CandP implements Serializable {
    Integer value;
    String label;
    List<parents> children;

    public CandP(Class aclass){
        this.value = aclass.getClassId();
        this.label = aclass.getClassName();
    }

    public void setChildren(List<Parent> parents) {
        children = new ArrayList<>();
        for(Parent parent : parents){
            children.add(new parents(parent));
        }
    }
}

@Data
@AllArgsConstructor
@NoArgsConstructor
class parents implements Serializable{
    Integer value;
    String label;

    public parents(Parent parent){
        this.value = parent.getParentId();
        this.label = parent.getParentName();
    }
}